//
//  ViewController.m
//  UI07_UINavigationController
//
//  Created by wyx on 16/3/17.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "ViewController.h"
#import "VCOFSecondViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self configForNavigationItem];
    [self configForNavigationbar];
}
- (void)viewWillApper:(BOOL)animated {
    [super viewWillAppear:animated];
    [self configForNavigationbar];
    
}
#pragma mark - 知识点1:UINavigationController
/** 
 * 导航控制器,控制界面的跳转
 * 需要指定一个根视图控制器
 * 创建过程详见 AppDelegate.m 文件
 * 在 VC.m 文件中 通过 vc.NAvigationController 找到离 VC 最近的 navigationController 对象
 */
#pragma mark - 知识点2:UINavigstionItem
- (void)configForNavigationItem{
    //中间title
     self.navigationItem.title = @"首页";
    //左边(leftBarButtonItem)
    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(handleCamere:)]autorelease];
    //右边(rightBarButtonItem)
    UIBarButtonItem *r1 = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(handleNext:)];
    UIBarButtonItem *r2 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"gur-project-10.png"] style:UIBarButtonItemStylePlain target:self action:@selector(handleMap:)];
    self.navigationItem.rightBarButtonItems = @[r1, r2];
    [r1 release];
    [r2 release];
}
-(void)handleCamere:(UIBarButtonItem *)camere {
    NSLog(@"dd");
}
- (void)handleMap:(UIBarButtonItem *)map {
    
}
/** 跳转到下一个界面 */
-(void)handleNext:(UIBarButtonItem *)next {
   //创建下一个页面对象
    VCOFSecondViewController *second = [[VCOFSecondViewController alloc] init];
    //navigation 推出新界面
    [self.navigationController pushViewController:second animated:YES];
    [second release];
}

#pragma mark - 知识点3:UINavigationBar
- (void)configForNavigationbar {
    //隐藏 bar
    self.navigationController.navigationBarHidden = NO;
    //barTintColor
    //self.navigationController.navigationBar.barTintColor = [UIColor redColor];
    self.navigationController.navigationBar.tintColor = [UIColor yellowColor];
    //风格
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    //是否透明
    self.navigationController.navigationBar.translucent = YES;
}
#pragma mark - 知识点4:通过 Navigation 跳转界面
/** 详见 handleNext: 方法 */

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
